package com.lwb.serviceBase;


import com.lwb.commonutils.ExceptionUtil;
import com.lwb.commonutils.Row;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理类
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    //全局异常
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Row error(Exception e){
        log.error(ExceptionUtil.getMessage(e));
        e.printStackTrace();
        return Row.ERROR();
    }
}
